
function setOption(chart, title, yAxisName, xAxisData, stData, etData, ptData) {
  var option = {
    color: ["#67E0E3", "#37A2DA", "#2B68D4"],
    title: {
      text: title,
      left: 'center'
    },
    legend: {
      data: ['学习时长', '有效学习时长', '效率值'],
      left: 'center',
      top: 30
    },
    grid: {
      top: 100
    },
    tooltip: {
      show: true,
      trigger: 'axis'
    },
    xAxis: {
      axisTick: {
        alignWithLabel: true
      },
      type: 'category',
      data: xAxisData,
    },
    yAxis: [{
      name: yAxisName,
      x: 'center',
      type: 'value',
      splitLine: {
        lineStyle: {
          type: 'dashed'
        }
      }
    }, {
      name: "效率(%)",
      x: 'center',
      type: 'value',
      min: 0,
      max: 100,
      position: 'right',
      splitLine: {
        lineStyle: {
          type: 'dashed'
        }
      }
    }],
    series: [{
      name: '学习时长',
      type: 'bar',
      data: stData
    }, {
      name: '有效学习时长',
      type: 'bar',
      data: etData
    }, {
      name: '效率值',
      type: 'line',
      yAxisIndex: 1,
      data: ptData,
      connectNulls:true
     
    }]
  };
  chart.setOption(option);
}

module.exports = {
  setOption: setOption
}
